#include "h_cc2640r2f_define.h"

//#include "h_cc2640r2f_uart.h"
#include "s_sc_uart.h"

#include <stdio.h>
//#include <stdarg.h>
#include <string.h>

#define H_CC2640R2F_DEBUG_TX        S_SC_UART_WriteBuff//H_CC2640R2F_UART_TxBuff

#ifdef UART_PRINTF
int fputc(int _c, register FILE *_fp)
{
    H_CC2640R2F_DEBUG_TX((const char *)&_c, 1);
    return(_c);
}

int fputs(const char *_ptr, register FILE *_fp)
{
    unsigned short len = strlen(_ptr);
    H_CC2640R2F_DEBUG_TX(_ptr, len);

    return len;
}
#endif

#define STR2HEX_LEN     256
static char str2hexdata[STR2HEX_LEN];
void str2hex(unsigned char *pAddr, unsigned short len)
{
  unsigned char     charCnt;
  char        hex[] = "0123456789ABCDEF";
  char        *pStr = str2hexdata;


  for (charCnt = 0; charCnt < len; charCnt++)
  {
    *pStr++ = hex[*pAddr >> 4];
    *pStr++ = hex[*pAddr++ & 0x0F];
  }

  *pStr = '\0';

  pStr = NULL;
}

void debug_hex(const unsigned char *data, unsigned short len)
{
    if(len >= STR2HEX_LEN)
    {
      // printf("Debug hex len error\r\n");
      return;
    }
    str2hex(data, len);
    printf("%s\r\n", str2hexdata);
}

